import { modelService } from "@/modules/model/service";
import { DiagramCustomizationManagementModel } from "../../DiagramCustomizationManagementModel";

type QueryParams = {
  projectId: string;
  modelId: string;
  row: any;
};
export class ContainElementModel {
  elementRange: any[] = [];
  queryParams: QueryParams;
  currentProjectId: string;
  isModelDisabled: boolean;

  constructor(public diagramCustomizationManagementModel: DiagramCustomizationManagementModel) {
    /*   this.stereotypeModelId = query.stereotypeModelId;
      this.constraintModelId = query.constraintModelId; */
    this.queryParams = diagramCustomizationManagementModel.queryParams;
    this.currentProjectId = this.queryParams?.projectId;
    this.isModelDisabled = diagramCustomizationManagementModel.isModelDisabled;
  }

  async initElementData(elementRange) {
    if (elementRange) {
      this.elementRange = await Promise.all(
        elementRange.map(async item => {
          const modelData = await modelService.getModelData(this.currentProjectId, item);
          return modelData;
        })
      ).then(res => res.filter(item => !!item));
    }
  }
}
